package com.sunday.haowushop.ui.mine.share;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import com.sunday.common.base.BaseActivity;
import com.sunday.haowushop.R;
import com.sunday.haowushop.common.BaseApp;
import com.sunday.haowushop.entity.Member;
import com.sunday.haowushop.http.ApiClient;
import com.sunday.haowushop.ui.mine.details.ShareDetailActivity;
import com.sunday.haowushop.widgets.ShareWindow;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by 刘涛 on 2017/5/14.
 */

public class ShareGiftActivity extends BaseActivity {

    @Bind(R.id.title_view)
    TextView titleView;
    @Bind(R.id.btn_share)
    Button btnShare;
    @Bind(R.id.rightTxt)
    TextView rightTxt;

    private long memberId;
    private Member member;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_share_gift);
        ButterKnife.bind(this);
        titleView.setText("分享好礼");
        rightTxt.setText("分享记录");
        member = BaseApp.getInstance().getMember();
        memberId = member.getId();

    }

    @OnClick(R.id.btn_share)
    void share() {
         /*1我要开店2分享店铺3普通商品4限时购商品)-memberId(会员Id)-productId(商品Id)-limitId(限时购时间段Id)
                    这四个参数没有值的传0
                    例如普通商品分享：http://weixin.zj-yunti.com/authorizationPage.html?param=3-1-14-0*/
        String shareUrl = String.format("%1$s%2$d-%3$d-%4$d-%5$d", ApiClient.SHARE_URL, 1, memberId, 0, 0);
        ShareWindow shareWindow = new ShareWindow(mContext, shareUrl, member.getNickName() + "给您送好礼了", member.getShopLogo(), null,
                mContext.getResources().getString(R.string.gift_share_desc), null,null);
        shareWindow.showPopupWindow(btnShare);
    }

    @OnClick(R.id.rightTxt)
    void onRecord(){
        intent = new Intent(mContext, ShareDetailActivity.class);
        startActivity(intent);
    }
}
